#ifndef _NET_API_H_
#define _NET_API_H_

#ifdef __cplusplus
extern "C" {
#endif

#include <sys/socket.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
#include <netdb.h>
#include <arpa/inet.h>
#include <sys/ioctl.h>
#include <net/if.h>
#include <net/if_arp.h>
#include <sys/un.h>
#include <pthread.h>
#include  <string.h>
#include <signal.h>
#include <fcntl.h>
#include <unistd.h>
#include <pthread.h>
#include "sf_net.h"

#include "sf_base_data.h"



typedef struct _net_op_st_ 
{
    	char strName[20];
	HANDLE (*Init)(HANDLE hNetHandle,int (*Recv)(HANDLE ,HANDLE ,char * ,int ,int),int (*Accpet)(HANDLE ,HANDLE ),int (*Close)(HANDLE ,HANDLE ),char * UID);
	int  (*Connect)(HANDLE hNetHandle,char * pStrIp,int iConnectPort);
	int (*Listen)(HANDLE hNetHandle,char * pStrBindIp,int iListenPort);
	int (*Accept)(HANDLE hNetHandle);
	int (*Recv)(HANDLE hNetHandle,void * pRecv,int iRecvLen,int iChannel);
	int (*Send)(HANDLE hNetHandle,void * pSend,int iSendLen,int iChannel);
	int (*Close)(HANDLE hNetHandle);
	int (*Destory)(HANDLE hNetHandle);
}NET_OP_ST;


typedef struct _net_transfer_st_ 
{  	
	int (*Recv)(HANDLE hNetHandle,HANDLE hNetCtrlHandle,void * pRecv,int iRecvBufLen,int iChannel);
	int (*Send)(HANDLE hNetHandle,HANDLE hNetCtrlHandle,void * pSend,int iSendLen,int iChannel);	
}NET_TRANSFER_MODE_ST;



typedef struct _net_protocol_st_ 
{  	
	HANDLE hNet;
	NET_OP_ST stNetOp;
	NET_TRANSFER_MODE_ST stNetTransMode;
}NET_PROTOCOL_ST;


typedef struct _NET_BASE_CTRL_ST_ 
{  		
	int iIsSvr;
	int iUserNum;
	HANDLE hNetHost;
	HANDLE hNetCli[SF_MAX_CLIENT_NUM];
	NET_OP_ST stNetOp;
	NET_TRANSFER_MODE_ST stNetTransMode;
	SF_NET_PARAM stNetParam;	
	pthread_mutex_t hOpMutex;
}NET_BASE_CTRL_ST;






#ifdef __cplusplus
}
#endif

#endif 
